package mmc.resource.models.collada;

import org.collada.x2005.x11.colladaSchema.SkinDocument.Skin;
import org.collada.x2005.x11.colladaSchema.SourceDocument.Source;

public class ColladaId_refDataSource{
	String[] data;
	int count;
	
	public ColladaId_refDataSource(Source s) {
		data = s.getIDREFArray1().getStringValue().split("\\ ");
		count = s.getTechniqueCommon().getAccessor().getCount().intValue();
	}
	
	public String get(int i){
		return data[i];
	}
	
	public int getCount(){
		return count;
	}
	
	static Source resolveSource(Skin skin, String sourceUrl){
		assert sourceUrl.charAt(0) == '#';
		sourceUrl = sourceUrl.substring(1);
		
		for(Source s : skin.getSourceArray()){
			if(s.getId().equals(sourceUrl))
				return s;
		}
		
		throw new RuntimeException("Invalid sourceUrl: "+sourceUrl);
	}
}